package com.example.helloapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

public class DateActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_date);
		Button b2  = (Button)findViewById(R.id.button2);
		b2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				DatePicker datePicker = (DatePicker)findViewById(R.id.datePicker1);
				String date = "" + datePicker.getDayOfMonth() + "/" +  (datePicker.getMonth()+1) + "/" +  datePicker.getYear();
				/*TextView dateView = (TextView)findViewById(R.id.dateView);
				dateView.setText(date);*/
				
				Intent intent = new Intent(DateActivity.this, MainActivity.class);
				
				intent.putExtra("date", date);
				startActivity(intent);
				//finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_date, menu);
		return true;
	}

}
